class StuController < ApplicationController
  layout "students"

  def index
#    session[:student_id] = "2"
#    session[:student_name] = "王伟"
#    session[:student_type] = "MBA"
  end

  #   显示相应学生类型的导师、名额信息
  def select_teacher
    stu_type = session[:student_type]
    @quantities = Quantity.select_tea(stu_type)
  end

  #  显示学生选择该教师的具体情况
  def choice_details
    tea_id = params[:id]
    @details = Choice.stu_choice_details(tea_id)
  end

  #  显示导师的信息
  def teacher_info
    stu_type = session[:student_type]
    @teacher_infos = Teacher.select_teacher_info(stu_type)
  end

  #  学生选择导师
  def stu_invite_tea
    stu_id = session[:student_id]
    tea_id = params[:id]

    # 执行邀请操作，在choice表中生成一条记录
    tf = Student.tea_invited( stu_id, tea_id )
    if tf
      t = Teacher.find(tea_id)
      flash[:notice] = "恭喜你已经邀请 " + t.tname + " 做导师"
      redirect_to(:action => 'choice_details', :id => tea_id)
    end
  end

  #  教师录取情况一览
  def choice_process
    @results = Teacher.get_teacher_result
  end
  
end
